﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "YccModelBase.h"
#include "IDbObject.h"
#include "GapIExtraData.h"

namespace gap
{
    /// \brief GAP的数据扩展组件
    /// 实现与 gcmp::IExternalDataComponent 基本一致
    class YCC_MODEL_BASE_EXPORT IExtraDataComponent : public gcmp::IDbObject
    {
        DEFINE_CAST_DERIVED(gap::IExtraDataComponent, gcmp::IDbObject)

    public:
        virtual ~IExtraDataComponent();

    public:
        static gcmp::OwnerPtr<gap::IExtraDataComponent> CreateDefaultComponent();

        /// \brief 获得GAP对象的扩展数据
        /// \return const std::vector<OwnerPtr<gap::IExtraData>>&
        virtual const std::vector<gcmp::OwnerPtr<gap::IExtraData>>& GetAllExtraDatas() const = 0;

        /// \brief 获得GAP对象的扩展数据
        /// \return std::vector<gcmp::OwnerPtr<gap::IExtraData>>&
        virtual std::vector<gcmp::OwnerPtr<gap::IExtraData>>& GetAllExtraDatasFW() = 0;

        /// \brief 注册扩展数据，扩展数据在对象中以 [Key, Value] 映射表的方式存储
        /// \param key         扩展数据所对应的key
        /// \param opExtraData 需要注册的扩展数据
        /// \return bool       注册成功返回true，否则返回false
        virtual bool RegisterExtraData(const std::wstring& key, gcmp::OwnerPtr<gap::IExtraData> opExtraData) = 0;

        /// \brief 注销扩展数据，扩展数据在对象中以 [Key, Value] 映射表的方式存储
        /// \param key   扩展数据所对应的key
        /// \return bool 注销成功返回true，否则返回false
        virtual bool UnregisterExtraData(const std::wstring& key) = 0;

        /// \brief 查询扩展数据，扩展数据在对象中以 [Key, Value] 映射表的方式存储
        /// \param key 扩展数据所对应的key
        /// \return const IExtraData* 扩展数据指针，如果没有查询到返回空指针
        virtual const gap::IExtraData* FindExtraData(const std::wstring& key) const = 0;

        /// \brief 查询扩展数据，扩展数据在对象中以 [Key, Value] 映射表的方式存储
        /// \param key 扩展数据所对应的key
        /// \return const IExtraData* 扩展数据指针，如果没有查询到返回空指针
        virtual gap::IExtraData* FindExtraDataFW(const std::wstring& key) = 0;
    };
}// namespace gap
